/*************************************************
Author: tony
Date: 01/24/2013
Description:
Notes:
*************************************************/

#ifndef __CMineCrystalConfig__
#define __CMineCrystalConfig__

#include "commerrno.h"
#include "commclass.h"
#include "CTArray.h"
#include "../common/CRandom.h"
#include "../item/CDropItemSubType.h"

class  CMineDropItemConfig
{
public:
    CMineDropItemConfig()
    {
        _ucItemType = 0;
        _ucCount = 0;
        _usItemId = 0;
    }

public:
    unsigned char                _ucItemType;
    unsigned char                _ucCount;
    unsigned short               _usItemId; //优先掉落
    CDropItemSubTypeConfigData::T_DROP_ITEM_SUBTYPE_CONFIG_KEY  _szItemSubType;  //没有配置_usItemId时,根据串掉落
};


class CMineTypeDropConfig
{
public:
    CMineTypeDropConfig()
    {
        Clear();
    }

    void Clear()
    {
        _stItemList.Clear();
    }

    int AddDropItem (CMineDropItemConfig& stConfigData, unsigned char & ucPos)
    {
        if (_stItemList.Size() >= MAX_MINE_DROP_COUNT)
        {
            return ERROR_MINE_CRYSTAL_CONFIG;
        }

        ucPos = _stItemList.AddOneItem(stConfigData);
        return 0;
    }

    int GetDropItem (unsigned char ucPos, CMineDropItemConfig& stConfigData)
    {
        if (ucPos > _stItemList.Size())
        {
            return ERROR_MINE_CONFIG_NONE;
        }

        stConfigData = _stItemList[ucPos];
        return 0;
    }

private:
    CTArray<CMineDropItemConfig, MAX_MINE_DROP_COUNT> _stItemList;
};

class CMineDrop
{
public:
    CMineDrop()
    {

    };

    //ucPos存放掉落物品在CMineTypeDropConfig中数组的下标
    int AddDropData(unsigned char ucMineType, unsigned char ucPos,int iDropRate);

    int DropItem (unsigned char ucMineType, unsigned char &ucPos);

    typedef CRandomSet<MAX_MINE_DROP_COUNT> T_MINE_TYPE_DROP;

public:
    CTArray<T_MINE_TYPE_DROP, MINE_TYPE_MAX> _stMineDrop;
};

class CDropItemData;
class CMineCrystalConfig
{
public:
	CMineCrystalConfig()
    {
    	Clear();
	}

	void Clear()
	{

    }

    int AddConfig (unsigned char ucMineType, CMineDropItemConfig & stConfig, int iDropRate);

    int DropItem (unsigned char ucMineType, CDropItemData & stDropData);

public:
    CMineDrop  _stMineDrop;
    CTArray<CMineTypeDropConfig, MINE_TYPE_MAX> _stMineConfig;
};


#endif // __CMineCrystalConfig__
